unit DIrr.RenderServices;

{$I DIrr.inc}

interface

uses
  DIrr.Types, DIrr.Structs;

type
  TRendererServices = class
  protected
    //! Destructor
    procedure _CPP_Destory; virtual; stdcall; abstract;
  public
    //! Can be called by an IMaterialRenderer to make its work easier.
    (** Sets all basic renderstates if needed.
    Basic render states are diffuse, ambient, specular, and emissive color,
    specular power, bilinear and trilinear filtering, wireframe mode,
    grouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and
    fog enabling.
    \param material The new material to be used.
    \param lastMaterial The material used until now.
    \param resetAllRenderstates Set to true if all renderstates should be
    set, regardless of their current state. *)
    procedure SetBasicRenderStates(const Material, LastMaterial: SMaterial;
      ResetAllRenderStates: Boolean); virtual; stdcall; abstract;

    //! Sets a vertex shader constant.
    (** Can be used if you created a shader using pixel/vertex shader
    assembler or ARB_fragment_program or ARB_vertex_program.
    \param data: Data to be set in the constants
    \param startRegister: First register to be set
    \param constantAmount: Amount of registers to be set. One register consists of 4 floats. *)
    procedure SetVertexShaderConstant(const Data: PF32; StartRegister: S32;
      ConstantAmount: S32 = 1); overload; virtual; stdcall; abstract;


    //! Sets a constant for the vertex shader based on a name.
    (** This can be used if you used a high level shader language like GLSL
    or HLSL to create a shader. Example: If you created a shader which has
    variables named 'mWorldViewProj' (containing the WorldViewProjection
    matrix) and another one named 'fTime' containing one float, you can set
    them in your IShaderConstantSetCallBack derived class like this:
    \code
    virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
    {
      video::IVideoDriver* driver = services->getVideoDriver();

      f32 time = (f32)os::Timer::getTime()/100000.0f;
      services->setVertexShaderConstant("fTime", &time, 1);

      core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION));
      worldViewProj *= driver->getTransform(video::ETS_VIEW);
      worldViewProj *= driver->getTransform(video::ETS_WORLD);
      services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16);
    }
    \endcode
    \param name Name of the variable
    \param floats Pointer to array of floats
    \param count Amount of floats in array.
    \return True if successful.
    *)
    function SetVertexShaderConstant(const Name: PAnsiChar; const Ints: PS32;
      Count: Integer): Boolean; overload; virtual; stdcall; abstract;

    function SetVertexShaderConstant(const Name: PAnsiChar; const Bools: PBoolean;
      Count: Integer): Boolean; overload; virtual; stdcall; abstract;

    function SetVertexShaderConstant(const Name: PAnsiChar; const Floats: PF32;
      Count: Integer): Boolean; overload; virtual; stdcall; abstract;


    //! Sets a pixel shader constant.
    (** Can be used if you created a shader using pixel/vertex shader
    assembler or ARB_fragment_program or ARB_vertex_program.
    \param data Data to be set in the constants
    \param startRegister First register to be set.
    \param constantAmount Amount of registers to be set. One register consists of 4 floats. *)
    procedure SetPixelShaderConstant(const Data: PF32; StartRegister: S32;
      ConstantAmount: S32 = 1); overload; virtual; stdcall; abstract;

    //! Sets a constant for the pixel shader based on a name.
    (** This can be used if you used a high level shader language like GLSL
    or HLSL to create a shader. See setVertexShaderConstant() for an
    example on how to use this.
    \param name Name of the variable
    \param floats Pointer to array of floats
    \param count Amount of floats in array.
    \return True if successful. *)
    function SetPixelShaderConstant(const Name: PAnsiChar; const Ints: PS32;
      Count: Integer): Boolean; overload; virtual; stdcall; abstract;

    function SetPixelShaderConstant(const Name: PAnsiChar; const Bools: PBoolean;
      Count: Integer): Boolean; overload; virtual; stdcall; abstract;

    function SetPixelShaderConstant(const Name: PAnsiChar; const Floats: PF32;
      Count: Integer): Boolean; overload; virtual; stdcall; abstract;

  end;

implementation

end.